<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page
	import="com.onlineMIS.common.Common_util,com.onlineMIS.ORM.entity.headQ.finance.ChainAcctFlowReportItem"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>千禧宝贝连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>
<script>
var ITEM_TYPE_P = "<%=ChainAcctFlowReportItem.ITEM_TYPE_PURCHASE%>";
var ITEM_TYPE_F = "<%=ChainAcctFlowReportItem.ITEM_TYPE_FINANCE%>";
$(document).ready(function(){
	parent.$.messager.progress('close'); 

	var params= $.serializeObject($('#SalesOrderSearchForm'));
	
	$('#dataGrid').datagrid({
		url : 'financeHQJSON!searchAcctFlow',
		queryParams: params,
		fit : true,
		fitColumns : true,
		border : false,
		checkOnSelect : false,
		selectOnCheck : false,
		singleSelect:true,
		rownumbers:true,
		nowrap : false,
		columns : [ [
					{field:'date', width:50,title:'单据日期'},
					{field:'chainName', width:240,title:'客户',fixed:true,
						formatter: function (value, row, index){
							return row.cust.name;
						}},
					{field:'itemTypeName', width:50,title:'单据种类'},
					{field:'quantity', width:50,title:'单据数量',
						formatter: function (value, row, index){
							return parseQuantity(row.quantity);
						}},
					{field:'amount', width:50,title:'单据金额'},
					{field:'comment', width:70,title:'单据摘要'},
					{field:'acctIncrease', width:40,title:'应收增加',
						formatter: function (value, row, index){
							return parseNumberValue(row.acctIncrease);
						}},
					{field:'acctDecrease', width:65,title:'应收减少',
						formatter: function (value, row, index){
							return parseNumberValue(row.acctDecrease);
						}},
					{field:'postAcct', width:70,title:'+应收/-应付金额',
						formatter: function (value, row, index){
							return (row.postAcct).toFixed(2);
						}},
					{field:'action', width:65,title:'详情',
						formatter: function (value, row, index){
							var url = "";
							var id = row.id;
							if (row.itemType == ITEM_TYPE_P)
								  url = "inventoryOrder!loadOrder?formBean.order.order_ID=" + id ;
							else if (row.itemType == ITEM_TYPE_F)
								  url = "financeHQJSP!getFHQ?formBean.financeBill.id="+id;
							
							var str = '';
							if (row.id != 0)
							    str += $.formatString('<a href="#" onclick="addTab3(\'{0}\',\'{1}\');"><img border="0" src="{2}" title="查看"/></a>', url, row.itemTypeName, '<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/update.png' );
							return str;
						}}
			     ]],
			     toolbar : '#toolbarSup',
		});
	});

function searchAcctFlow(){
	var params= $.serializeObject($('#SalesOrderSearchForm'));
	$('#dataGrid').datagrid('load',params); 
}

function downloadAcctFlow(){
	document.SalesOrderSearchForm.action="financeHQJSP!downloadAcctFlow";
	document.SalesOrderSearchForm.submit();
}

function downloadAcctFlowDetails(){
	 $.messager.confirm('下载提示', '当单据日期时间超过10天时,下载此单据会比较耗时,确认是否下载此单据?', function(r){
         if (r){
        		document.SalesOrderSearchForm.action="financeHQJSP!downloadAcctFlowDetails";
        		document.SalesOrderSearchForm.submit();
         }
     });
}
</script>
</head>
<body>

	
<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'north',border:false" style="height: 125px;">
	<s:form id="SalesOrderSearchForm" name="SalesOrderSearchForm"
		action="financeHQJSP!downloadAcctFlow" 
		theme="simple" method="POST">
		<table width="98%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" border="0">
						<tr>
							<td height="50" colspan="7">
								<div class="errorAndmes">
									<s:actionerror cssStyle="color:red" />
									<s:actionmessage cssStyle="color:blue" />
								</div>
								<table width="100%" border="0">
									<tr class="PBAOuterTableTitale">
										<td height="35" colspan="4">客户财务往来账目:
										</td>
									</tr>
									<tr>
										<td width="24%"><%@ include file="../custMgmt/CustInput.jsp"%>
											<input type="hidden" id="indicator" name="formBean.indicator" value="-1"/></td>
										<td width="20%"><strong>单据日期：  </strong><s:textfield id="startDate"
											name="formBean.searchStartTime" cssClass="easyui-datebox"
											data-options="width:100,editable:false" /> &nbsp; 至&nbsp; <s:textfield
											id="endDate" name="formBean.searchEndTime" cssClass="easyui-datebox"
											data-options="width:100,editable:false" /></td>	
										<td width="5%" align="center"><strong>客户标签：</strong></td>
										<td >
														<input class="easyui-tagbox" name="formBean.tagGroups" id="tags"  style="width:400px;" data-options="
											                url: 'headQCustMgmtJSONAction!listCusTags',
											                method: 'get',
											                groupField:'groupName',
											                value: '',
											                valueField: 'id',
											                textField: 'tagName',
											                limitToList: true,
											                hasDownArrow: true,
											                prompt: '请选择客户标签',
											                tagStyler: function(value){
										                    if (value >0 && value <=3){
										                        return 'background:#ffd7d7;color:#c65353';
										                    } else if (value >= 4 && value <17){
										                        return 'background:#76EEC6;color:#c65353';
										                    }else if (value >= 17 && value <19){
										                        return 'background:#7EC0EE;color:#c65353';
										                    }else if (value >= 19 ){
										                        return 'background:#EEB422;color:#c65353';
										                    }
										                }
											                ">
														</td>	
									</tr>
									<tr>
										
									</tr>															
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		</s:form>
	</div>
			<div data-options="region:'center',border:false">
			
			<div id="toolbarSup" style="display: none;">
				<a onclick="searchAcctFlow();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-search',plain:true">查询账目</a> <a
					onclick="downloadAcctFlow();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-print',plain:true">下载账目</a><a
					onclick="downloadAcctFlowDetails();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-print',plain:true">下载账目明细</a>
			</div>
			<table id="dataGrid">
			</table>
		</div>
</div>	

</body>
</html>